﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NGinnBPM.Lib.Data;
using NGinnBPM.Lib.Messages;
using Newtonsoft.Json;
using NGinnBPM.Lib.Util;

namespace NGinnBPM.Runtime.Messages
{

    /// <summary>
    /// Enable task message
    /// Handler should reply with 'EnableTaskMessageResponse' 
    /// or GenericFailure on error.
    /// </summary>
    [Serializable]
    public class EnableTaskMessageBase : ICorrelatedMessage
    {
        public string CorrelationId { get; set; }
        public string NewTaskInstanceId { get; set; }
        public string TaskId { get; set; }
        public string ProcessDefinition { get; set; }
        public string ParentTaskInstanceId { get; set; }
        public string ProcessInstanceId { get; set; }
        /// <summary>shared id - if two or more tasks share a token in a mutually exclusive way (deferred choice) they will have the same shared id</summary>
        public string SharedId { get; set; }

        public override string ToString()
        {
            return string.Format("{0} {1}.{2} [{3}->{4}]", GetType().Name, ProcessDefinition, TaskId, ParentTaskInstanceId, NewTaskInstanceId);
        }
    }

    [Serializable]
    public class EnableTaskMessage : EnableTaskMessageBase
    {
        [JsonConverter(typeof(TaskDataJsonConverter))]
        public Dictionary<string, object> InputData { get; set; }
    }

    [Serializable]
    public class EnableMultiInstanceTaskMessage : EnableTaskMessageBase
    {
        public Dictionary<string, object>[] MultiInputData { get; set; }
    }

    

}
